---------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  /Users/Jeff/Dropbox/TermLimits/Replication/Models/IndexEmpirical/Unconditional/Primary/PredictedValues.log
  log type:  text
 opened on:  12 Nov 2016, 21:02:03

. cd "/Users/Jeff/Dropbox/TermLimits/Replication/Models/IndexEmpirical/Unconditional/Primary";
/Users/Jeff/Dropbox/TermLimits/Replication/Models/IndexEmpirical/Unconditional/Primary

. **************************************************************;
. *Author: Jeff Carter                                         *;
. *Date: Wednesday, December 3, 2014                              *;
. *Purpose: Simulating Predictions                *;
. **************************************************************;
. *********************************;
. **      Peace to War            *;
. *********************************;
. use "/Users/Jeff/Dropbox/TermLimits/Replication/Models/IndexEmpirical/Unconditional/Primary/SimData.dta";

. postutil clear;

. postfile mypost prob_hat0 lo0 hi0 prob_hat1 lo1 hi1 diff_hat0 diff_lo0 diff_hi0
>                 using PredictedValues, replace;
(note: file PredictedValues.dta not found)

. noisily display "start";
start

. local a=0 ;

. while `a' < .1 { ;
  2. {;
  3.  scalar h_Accountable =   0  ;
  4. scalar h_LameDuck= 1  ;
  5. scalar h_Civilian = 0;
  6. scalar h_Military = 1;
  7. scalar h_Constant = 1;
  8. scalar h_Parliament = 0;
  9. scalar h_CivilWar = 0;
 10. scalar h_GDPpc =  12589.35;
 11. scalar h_Growth = 3.453132;
 12. scalar h_MajorPower = 0;
 13. scalar h_Borders = 2;
 14. scalar h_Mobilization =  -.0008714 ;
 15. scalar h_Time = 5;
 16.  scalar h_Female =0 ;
 17.   scalar h_Rivalry = 0 ;
 18.  scalar h_Hawkish = 0;
 19. generate x_betahat0 = MG_b1*h_Accountable
>     + MG_b2*h_Hawkish
>     + MG_b3*h_Rivalry
>     + MG_b4*h_Borders
>     + MG_b5*h_Parliament
>     + MG_b6*h_Female 
>     + MG_b7*h_Time 
>     + MG_b8*(h_Time^2)
>     + MG_b9*(h_Time^3)
>     + MG_b10*h_Constant;
 20. generate x_betahat1 = MG_b1* h_LameDuck
>     + MG_b2*h_Hawkish
>     + MG_b3*h_Rivalry
>     + MG_b4*h_Borders
>     + MG_b5*h_Parliament
>     + MG_b6*h_Female 
>     + MG_b7*h_Time 
>     + MG_b8*(h_Time^2)
>     + MG_b9*(h_Time^3)
>     + MG_b10*h_Constant;
 21.  gen prob0=1/(1+exp(-x_betahat0));
 22. gen prob1=1/(1+exp(-x_betahat1));
 23.  gen diff0=prob1-prob0 ;
 24. egen probhat0=mean(prob0) ;
 25. egen probhat1=mean(prob1) ;
 26. egen diffhat0=mean(diff0) ;
 27. tempname prob_hat0 lo0 hi0 prob_hat1 lo1 hi1 diff_hat0 diff_lo0 diff_hi0;
 28.     _pctile prob0, p(2.5,97.5) ;
 29.     scalar `lo0'=r(r1) ;
 30.     scalar `hi0'=r(r2) ;
 31.     _pctile prob1, p(2.5,97.5) ;
 32.     scalar `lo1'=r(r1) ;
 33.     scalar `hi1'=r(r2) ;
 34.     _pctile diff0, p(2.5,97.5) ;
 35.     scalar `diff_lo0'= r(r1) ;
 36.     scalar `diff_hi0'=r(r2) ;
 37.     scalar `prob_hat0'=probhat0 ;
 38.     scalar `prob_hat1'=probhat1 ;
 39.     scalar `diff_hat0'=diffhat0 ;
 40.     post mypost (`prob_hat0') (`lo0') (`hi0') (`prob_hat1') (`lo1') (`hi1') (`diff_hat0') (`diff_lo0') (`diff_hi0')
> 
> 
>     ;
 41.     } ;
 42.     drop    x_betahat0 x_betahat1 prob0 prob1 diff0 probhat0 probhat1 diffhat0;
 43.     local a=`a'+ .1 ;
 44.     display "." _c ;
 45.     } ;
.
. display "" ;


.  postclose mypost ;

. use PredictedValues, clear;

. sum;

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
   prob_hat0 |         1    .0457494           .   .0457494   .0457494
         lo0 |         1    .0307663           .   .0307663   .0307663
         hi0 |         1    .0657578           .   .0657578   .0657578
   prob_hat1 |         1    .0250115           .   .0250115   .0250115
         lo1 |         1    .0156891           .   .0156891   .0156891
-------------+--------------------------------------------------------
         hi1 |         1    .0379484           .   .0379484   .0379484
   diff_hat0 |         1    -.020738           .   -.020738   -.020738
    diff_lo0 |         1    -.037956           .   -.037956   -.037956
    diff_hi0 |         1   -.0060703           .  -.0060703  -.0060703

. saveold PredictedValues, replace;
file PredictedValues.dta saved

. log close;
      name:  <unnamed>
       log:  /Users/Jeff/Dropbox/TermLimits/Replication/Models/IndexEmpirical/Unconditional/Primary/PredictedValues.log
  log type:  text
 closed on:  12 Nov 2016, 21:02:03
---------------------------------------------------------------------------------------------------------------------------
